package com.example.dml.generics;

import java.util.Date;

/**
 * @Authors：gaoyang
 * @CreateTime：2021-10-29
 * @Description：todo
 */
public class Generic <T>{

    private T t;

    public T get() {
        return t;
    }

    public void set(T t) {
        this.t = t;
    }

    public static void main(String[] args) {
        //这种形式不需要类型转化
        Generic<Tbinfo> generic = new Generic<Tbinfo>();
        generic.set(new Tbinfo(1,new Date()));
        Tbinfo tb1 = generic.get();
        System.out.println(tb1.toString());
        //这种方式需要强制类型转化
        Generic generic1 = new Generic();
        generic1.set(new Tbinfo(1,new Date()));
        Tbinfo tb2 = generic.get();
        System.out.println(tb2.toString());
    }
}
